Repository navigation
feat(libc): implement collate<wchar_t>::_Getcat - #1982
overlordxrz-source wants to merge 4 commits into
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
The local wide-collate tests are detailed and CI now passes, but the PR only has import-list evidence and explicitly says it has not been run with either title. CONTRIBUTING.md says import lists alone do not establish that a title reaches these exports and asks for a reproduced failure or another concrete demonstrated need. The central wide-string layout/vtable and hash assumptions also need a source or runtime trace; static_asserts only check the proposed layout against itself. Finally, TechnicalDebt currently says Cyberpunk imports _Atomic_assert without calling it. Please add evidence for a reached export and ground the wide ABI/behavior before review.
Cyberpunk 2077 imports std::_Atomic_assert without calling it, so the export keeps throwing until a title is shown to reach it.
|
Thanks. I made three changes:
|
|
Closing: there's no stop line from main for |
…ayout is taken from Harvested from upstream (closed unmerged); library completion 2831/3229 -> 2835/3232. (changelog conflict: kept both) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011krDVCnnMQPaEFEqCDnKmA
What
_ZNSt7collateIwE7_GetcatEPPKNSt6locale5facetEPKS1_(std::collate<wchar_t>::_Getcat) still throws onmain. Dreaming Sarah (PPSA02929, import list in #265) imports it.std::_Atomic_asserthas been taken out of this PR. Cyberpunk 2077 imports it but never calls it, so its stub stays as it is onmain.The wide facet mirrors the existing
collate<char>::_Getcatfrom #885. That PR read the narrow facet's layout from the console'slibc.prx(the copy in Astro's Playroom). Nobody has disassembled the wide one, so its layout here comes from the fact that both facets are instances of the same Dinkumware templates. #885 found that the narrow facet behaves the way MS STL's sources of the same line do: FNV-1a indo_hash, a 16-byte inline string buffer, and thep[-1]large-allocation header at 0x1000 bytes. Each point below is the_Elem = wchar_tform of that template, plus a source for it:collate<_Elem>is one class template: MS STL<locale>. Its virtuals are the destructor, thendo_compare,do_transformanddo_hash, in the same order for every_Elem. So the wide facet has the narrow facet's 0x20-byte object and its vtable slot offsets (0x20/0x28/0x30). Only the element type of the arguments changes.wchar_tis 16-bit unsigned on PS4 and PS5: clang'sPSOSTargetInfosetsWCharType = UnsignedShort(OSTargets.h).do_compare. In the C locale, Dinkumware'swcscollhas no collation table (_WCostateis{{0}}, "1-to-1 inline": xwcostate.c). So_CWcsxfrmcopies the characters unchanged (xwcsxfrm.c), and_Wcscollxcompares them withwmemcmp(wcscoll.c).wmemcmpreturns -1/+1 on the first differingwchar_t(wmemcmp.c). The result is the order of the unsigned 16-bit values, with the shorter range first on a tie. This is the wide form of the narrowstrcoll/strcmpresult in feat(libc): implement collate<char>::_Getcat #885.do_transform. The C-locale transform is the same one-to-one copy. The result is a gueststd::wstring.basic_stringkeeps the narrow layout (proxy word at 0x0, buffer/pointer union at 0x8, size at 0x18, capacity at 0x20), and its inline buffer is_BUF_SIZE = 16 / sizeof(value_type)= 8 elements, so 7 characters plus the terminator (xstring). The over-aligned large-allocation path starts at_Big_allocation_threshold = 4096bytes (xmemory). That is 2047 wide characters plus the terminator, so those results throw, like the 4095-character limit on the narrow side.do_hash. MS STL hashescount * sizeof(_Elem)bytes with FNV-1a (_Hash_array_representation, called fromcollate::do_hash). Forwchar_ton x86-64 those are the little-endian bytes of each character. Forcharthis gives the FNV-1a that feat(libc): implement collate<char>::_Getcat #885 saw on the console.What this does not establish: the wide instance has not been disassembled or traced on a console, so these points are inferred from the template and not measured. TechnicalDebt says so, along with the C-locale-only and null-table limits it shares with the narrow facet. The
static_asserts inGuestLocale.hpponly keep the struct in line with the offsets above. They are not evidence.#1498 also changes this stub as part of a larger change, and the two conflict in
LocaleSupport.cpp.Log
I don't own Dreaming Sarah, so I can't paste a stop line from
main. The only evidence that a title reaches this export is the import list in #265.Tested
aarch64 Debian 13 host. The full project can't be built here because it needs x86-64.
core/libs/tests/GuestCollate.cppcovers the wide facet:_Getcatcreation and reuse, compare ordering and prefix cases, transform inline and heap results, and hash equality. It passes in a native build ofGuestCollate.cpp,LocaleSupport.cppandApplicationHeap.cppunder UBSan.LocaleSupport.cpp,Export.cppand the test compile for x86_64-linux-gnu and x86_64-windows-gnu with-Wall -Wextra(Zig 0.17 clang). The only warning is the existing-Wreturn-type-c-linkagefromGeneral.hpp.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main. The one other open PR that changes this function is feat(libs): implement font, libc, libkernel and misc prx stubs #1498, which also changes this stub as part of a larger change; see WhatNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)